package exception;


import java.sql.SQLOutput;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");

        try {
            String str = "hello";
            String str1 = null;
            System.out.println(str1.length());
            System.out.println(str.charAt(5));
        }catch (NullPointerException e){
            System.out.println("空指针异常");
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("字符串索引越界了");
        }
        System.out.println("程序结束了");
    }
}
